//
//  LJCTimeViewController.m
//  WZLProduct
//
//  Created by 陆静聪 on 16/3/24.
//  Copyright © 2016年 HaiTeng. All rights reserved.
//

#import "LJCTimeViewController.h"

@interface LJCTimeViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) UITableView *rootTable;
@property (nonatomic, retain) NSArray *timeArr;
@property (nonatomic, retain) NSIndexPath *index;

@end

@implementation LJCTimeViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.timeArr = @[@"10", @"20", @"30", @"60", @"90"];
    [self createTable];
}

- (void)createTable {
    _rootTable = [[UITableView alloc] initWithFrame:kScreen style:UITableViewStylePlain];
    _rootTable.delegate = self;
    _rootTable.dataSource = self;
    [self.view addSubview:_rootTable];
    _rootTable.rowHeight = 60;

   
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _timeArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    
    UITableViewCell *timeCell = [tableView dequeueReusableCellWithIdentifier:@"LJCUITableViewCell"];
    if (!timeCell) {
        timeCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"LJCUITableViewCell"];
    }
    
    timeCell.textLabel.text = [NSString stringWithFormat:@"%@分钟", _timeArr[indexPath.row]];
    return timeCell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    CGFloat time = [_timeArr[indexPath.row] floatValue] * 60;
    [[LJCMusicPlay shareMusicPlayer] timingOff:time];

    
    UITableViewCell *cell = [_rootTable cellForRowAtIndexPath:indexPath];
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    UITableViewCell *cell1 = [_rootTable cellForRowAtIndexPath:_index];
        cell1.accessoryType = UITableViewCellAccessoryNone;
    _index = indexPath;

    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
